home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr22
/
fcheck10.zip
/
REPEAT.DOC
< prev
next >
Wrap
Text File
|
1992-12-02
|
7KB
|
168 lines
REPEAT v2.2
(c) 1992 by Ben Bernard
Intro:
The original idea of REPEAT was to allow you to apply a single command to
multiple files. This is needed for such commands as TYPE, which don't
accept wildcards. The solution was REPEAT TYPE # FOR *.TXT, where # was
replaced by each successive file processed.
In using v 1.0 I found many other things which I thought should be added.
You can see the result below. Macro substitutions allow REPEAT to perform
complex decisions based on variables related to the files being processed.
New to version 2.1 is a wildcard matching routine which increases flexibility
and a subdirectory recursion option, along with new macros and operators.
REPEAT is really a prototype, written with MS BASIC PDS 7.1, of a future
program to be implemented in C when I get time to do so. In the meantime,
if I have left what you deem to be a useful feature out of REPEAT, drop me
a line at the adresses listed at the end.
Legal stuff:
You use this program AT YOUR OWN RISK. By using REPEAT, you
agree to absolve me of all claims for damage to any hardware, software, or
data which might be caused by this program. You are hereby granted license to
use REPEAT for any use and any period of time, provided you do not modify the
code in any way. This software may be distributed only in its original and
complete package, either in the original ZIP file or in an equivalent archive.
No fee can be charged for this software. Disk duplicators and BBSs may,
however, charge a fee for their services. While registration of this
software is not required, donations are appreciated.
Usage: REPEAT {command} FOR {filespec} IF {mask}
{command} will be executed once for each file in {filespec} for which
{mask} evaluates to true.
{command} can contain any DOS command, plus the macros listed below.
{filespec} can have full pathname and more.
{mask} is optional and can contain any of the macros and operators below.
Macros: Operators:
$bd space on drive d { } = ~
$d file drive greater less equal match
$e extension @ & !
$f filename or and not
$n basename
$p[x] full path (0=no end \ 1=no drive 2=from spec 3=last level)
$s file size
$t file time
$y file date
$[ ] left justify macros between [ ]
$r ] right justify macros between r ]
$c ] center macros between c ]
$() pass as a literal the text between ()
$$ $
$_ new line (allows multiple commands)
$, < \
$. > }these must be used to delay DOS redirection
$\ | /
Some details:
As I mentioned in the v2.0 docs, the directory is no longer preloaded. This
was changed to allow traversing of directory trees.
To use DOS redirection within {command} you must use the $, $. and $\ macros.
You may now use the $() macro to pass macros literally, thus making it
possible to have REPEAT call itself recursively (probably not a good idea).
Paths MUST end with '\' or '/'. If you use D:\TEST as the filespec, REPEAT
will interpret D:\ as the path and TEST as the filespec. If you use D:\TEST\
REPEAT will interpret D:\TEST\ as the path and *.* as the filespec.
Multiple filespecs can be included in {filespec} by separating them with commas.
Any path ending with '/' will cause REPEAT to recurse through all of its
subdirectories. Paths ending in '\' will not be recursed.
Filespec matching is done by REPEAT, and not by DOS. This means, among other
things, that *P* will match only files with a P in their name, and not all
files. It also means that a name is a name, and extensions, including the
'.' are treated as part of the name. *.* is still a legitimate spec, but
will match the same as '*' because all files, extension or not, have the '.'.
The path macro works as follows:
Assume the directory structure C:\DOS\DOC
REPEAT echo $p $p0 $p1 $p2 $p3 for c:/. will produce the following output:
C:\DOS\ C:\DOS \DOS DOS DOS
C:\DOS\DOC\ C:\DOS\DOC \DOS\DOC DOS\DOC DOC
NOTE that because root directories have no '.' entry, they are not processed
by 'for "/."'
Directories are not normally processed by REPEAT. However, you can tell
REPEAT to process directory entries using the . and .. filespecs. These
are not exactly like the DOS equivalents. The . filespec tells REPEAT
to execute the commands once for each directory recursed. The .. filespec
tells REPEAT to process the commands once for each directory entry. The
DOS . and .. directory entries are _never_ processed.
The disk space macro ($b) can accept the file drive macro ($d) as a parameter.
The justification macros ($[ $r $c) pack as many spaces in as there are
characters between the macro and the terminator (exclusive). The space
between can contain other macros, EXCEPT other justification macros and
the new line macro.
The equal operator '=' does a straight, no wildcards, comparison. To use
wildcards, use the match operator '~'.
The new line macro allows multiple shelled commands per line. Each $_ causes
the command up to that point to be executed in a shell.
The comparison operators treat dates specially so that they will be handled
properly.
Pressing <ESC> during execution will result in REPEAT pausing when it regains
control, at which time you can decide to abort REPEAT or continue.
Nothing in REPEAT is case sensitive.
Examples:
repeat echo $[$f ] $r$s ] $y $t for *.* if $y=10-11-1990
Produces a DOS-like directory of all files with date 10-11-1990.
repeat copy $f a:\ for *.* if $ba}$s
Copies files from current directory to drive a as long as there is space
for them. Note that the disk space check is done dynamically, so that
as each file is copied onto drive a, the space available is adjusted
accordingly.
repeat del $n.obj for *.bas
Deletes .OBJ files with same basename as existing .BAS files.
repeat copy $d:$p1\$f c:\$d$f for d:/*.* e:/*.* f:/*.* if $bc>$s
Copies all files from d, e, and f to their respective directories
in c, as long as there is space on c for the file. Note that the
directories must exist already.
repeat md c:\$p2 for d:/. e:/. f:/.
Creates on C the directory structures of D, E, and F.
History:
12-02-1992 2.2 Added path options 0-3, changed recursion order,
allow use of . and .. for directory operations,
added $_ for newline.
01-01-1992 2.1 Added wildcard matching, recursion, and some macros.
Changed to dynamic method of reading directories.
12-20-1991 2.0 Replaced EXCEPT with IF, added macros and operators.
? 1.1 Added the except clause.
? 1.0 Original version of REPEAT, never release to the public.
Suggestions, donations, feedback, or just plain comments can be addressed to:
InterNet: ben.bernard@channel1.com
RIME: R/O Ben Bernard ->CHANNEL
SnailMail: Ben Bernard
709 E 17th St
Houston, TX 77008